package com.pshcp.doctor.api;

import com.framework.base.PageList;
import com.framework.base.ResultBuilder;
import com.framework.base.ResultDTO;
import com.framework.exception.BizException;
import com.framework.logaop.Log;
import com.framework.logaop.LogSourceEnum;
import com.framework.logaop.LogTypeEnum;
import com.pshcp.doctor.ao.diagnosis.DoctorDiagnosisPageAO;
import com.pshcp.doctor.ao.diagnosis.DoctorDiagnosisVO;
import com.pshcp.doctor.tool.DoctorDiagnosisTool;
import com.pshcp.domain.dto.PatientOnlineOrderDTO;
import com.pshcp.domain.model.PatientOnlineOrder;
import com.pshcp.service.PatientOnlineOrderService;
import com.pshcp.service.PatientService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2022/11/6 19:48
 */
@Api(tags = {"医生端-专家问诊接口"})
@Slf4j
@RestController
@RequestMapping("/api/doctor/diagnosis")
public class DoctorDiagnosisAPI {

    @Autowired
    private PatientOnlineOrderService patientOnlineOrderService;

    @Autowired
    private PatientService patientService;

    @Deprecated
    @ApiOperation("获取专家问诊列表(分页)")
    @Log(source = LogSourceEnum.APP, type = LogTypeEnum.SELECT, desc = "获取专家问诊列表(分页)")
    @PostMapping("getDoctorDiagnosisPage")
    public ResultDTO<PageList<DoctorDiagnosisVO>> getDoctorDiagnosisPage(@RequestBody DoctorDiagnosisPageAO doctorDiagnosisPageAO) throws BizException {
        PatientOnlineOrderDTO patientOnlineOrderDTO = DoctorDiagnosisTool.buildGetDoctorSendMessagePage(doctorDiagnosisPageAO);
        PageList<PatientOnlineOrder> pageList = patientOnlineOrderService.list(patientOnlineOrderDTO);
        PageList<DoctorDiagnosisVO> page = DoctorDiagnosisTool.buildGetDoctorDiagnosisPage(patientService, pageList);
        return ResultBuilder.success(page);
    }
}
